package cn.hpclub.server.bean;

import cn.hpclub.server.util.PropertiesUtils;
import org.apache.commons.lang.StringUtils;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;


public class NewSystemConfig extends SystemConfig {

    private final PropertiesUtils.Prop prop;

    public NewSystemConfig() {
        prop = PropertiesUtils.use("hpclub.properties");
    }

    @Override
    public String getSystemName() {
        return prop.get("systemName");
    }

    @Override
    public String getSystemVersion() {
        return prop.get("systemVersion");
    }

    @Override
    public String getSystemDescription() {
        return prop.get("systemDescription");
    }

    @Override
    public Boolean getIsInstalled() {
        return Boolean.valueOf(prop.get("isInstalled"));
    }

    @Override
    public String getShopName() {
        return prop.get("shopName");
    }

    @Override
    public String getShopUrl() {
        return prop.get("shopUrl");
    }

    @Override
    public String getShopLogo() {
        return prop.get("shopLogo");
    }

    @Override
    public String getHotSearch() {
        return prop.get("hotSearch");
    }

    @Override
    public String getMetaKeywords() {
        return prop.get("metaKeywords");
    }

    @Override
    public String getMetaDescription() {
        return prop.get("metaDescription");
    }

    @Override
    public String getAddress() {
        return prop.get("address");
    }

    @Override
    public String getPhone() {
        return prop.get("phone");
    }

    @Override
    public String getZipCode() {
        return prop.get("zipCode");
    }

    @Override
    public String getEmail() {
        return prop.get("email");
    }

    @Override
    public CurrencyType getCurrencyType() {
        return CurrencyType.valueOf(prop.get("currencyType"));
    }

    @Override
    public String getCurrencySign() {
        return prop.get("currencySign");
    }

    @Override
    public String getCurrencyUnit() {
        return prop.get("currencyUnit");
    }

    @Override
    public Integer getPriceScale() {
        return Integer.valueOf(prop.get("priceScale"));
    }

    @Override
    public RoundType getPriceRoundType() {
        return RoundType.valueOf(prop.get("priceRoundType"));
    }

    @Override
    public Integer getOrderScale() {
        return Integer.valueOf(prop.get("orderScale"));
    }

    @Override
    public RoundType getOrderRoundType() {
        return RoundType.valueOf(prop.get("orderRoundType"));
    }

    @Override
    public String getCerttext() {
        return prop.get("certtext");
    }

    @Override
    public Integer getStoreAlertCount() {
        return Integer.valueOf(prop.get("storeAlertCount"));
    }

    @Override
    public StoreFreezeTime getStoreFreezeTime() {
        return StoreFreezeTime.valueOf(prop.get("storeFreezeTime"));
    }

    @Override
    public Integer getUploadLimit() {
        return Integer.valueOf(prop.get("uploadLimit"));
    }

    @Override
    public Boolean getIsLoginFailureLock() {
        return Boolean.valueOf(prop.get("isLoginFailureLock"));
    }

    @Override
    public Integer getLoginFailureLockCount() {
        return Integer.valueOf(prop.get("loginFailureLockCount"));
    }

    @Override
    public Integer getLoginFailureLockTime() {
        return Integer.valueOf(prop.get("loginFailureLockTime"));
    }

    @Override
    public Boolean getIsRegister() {
        return Boolean.valueOf(prop.get("isRegister"));
    }

    @Override
    public String getWatermarkImagePath() {
        return prop.get("watermarkImagePath");
    }

    @Override
    public WatermarkPosition getWatermarkPosition() {
        return WatermarkPosition.valueOf(prop.get("watermarkPosition"));
    }

    @Override
    public Integer getWatermarkAlpha() {
        return Integer.valueOf(prop.get("watermarkAlpha"));
    }

    @Override
    public Integer getBigProductImageWidth() {
        return Integer.valueOf(prop.get("bigProductImageWidth"));
    }

    @Override
    public Integer getBigProductImageHeight() {
        return Integer.valueOf(prop.get("bigProductImageHeight"));
    }

    @Override
    public Integer getSmallProductImageWidth() {
        return Integer.valueOf(prop.get("smallProductImageWidth"));
    }

    @Override
    public Integer getSmallProductImageHeight() {
        return Integer.valueOf(prop.get("smallProductImageHeight"));
    }

    @Override
    public Integer getThumbnailProductImageWidth() {
        return Integer.valueOf(prop.get("thumbnailProductImageWidth"));
    }

    @Override
    public Integer getThumbnailProductImageHeight() {
        return Integer.valueOf(prop.get("thumbnailProductImageHeight"));
    }

    @Override
    public String getDefaultBigProductImagePath() {
        return prop.get("defaultBigProductImagePath");
    }

    @Override
    public String getDefaultSmallProductImagePath() {
        return prop.get("defaultSmallProductImagePath");
    }

    @Override
    public String getDefaultThumbnailProductImagePath() {
        return prop.get("defaultThumbnailProductImagePath");
    }

    @Override
    public String getAllowedUploadImageExtension() {
        return prop.get("allowedUploadImageExtension");
    }

    @Override
    public String getAllowedUploadMediaExtension() {
//        return prop.get("allowedUploadAppExtension");
        return "";
    }

    @Override
    public String getAllowedUploadFileExtension() {
        return prop.get("allowedUploadFileExtension");
    }

    @Override
    public String getAllowedUploadAppExtension() {
        return prop.get("allowedUploadAppExtension");
    }

    @Override
    public String getSmtpFromMail() {
        return prop.get("smtpFromMail");
    }

    @Override
    public String getSmtpHost() {
        return prop.get("smtpHost");
    }

    @Override
    public Integer getSmtpPort() {
        return Integer.valueOf(prop.get("smtpPort"));
    }

    @Override
    public String getSmtpUsername() {
        return prop.get("smtpUsername");
    }

    @Override
    public String getSmtpPassword() {
        return prop.get("smtpPassword");
    }

    @Override
    public PointType getPointType() {
        return PointType.valueOf(prop.get("pointType"));
    }

    @Override
    public Double getPointScale() {
        return Double.valueOf(prop.get("pointScale"));
    }

    @Override
    public List<String> getHotSearchList() {
        String hotSearch = prop.get("hotSearch");
        return StringUtils.isNotEmpty(hotSearch) ? Arrays.asList(hotSearch.split(HOT_SEARCH_SEPARATOR))
                : new ArrayList<String>();
    }

    @Override
    public int getTokenExpireTime() {
        return Integer.valueOf(prop.get("tokenExpireTime"));
    }

    @Override
    public String getUploadDir() {
        return prop.get("uploadDir");
    }

    @Override
    public String getDataSyncDir() {
        return prop.get("dataSyncDir");
    }

    @Override
    public String getHostPrefix() {
        return prop.get("hostPrefix");
    }

    @Override
    public String getCmccHostPrefix() {
        return prop.get("cmccHostPrefix");
    }

    @Override
    public String getYaxinHostPrefix() {
        return prop.get("yaxinHostPrefix");
    }

    @Override
    public String getTariffBusiness() {
        return prop.get("tariffBusiness");
    }

    @Override
    public String getPayQrCodeDir() {
        return prop.get("payQrCodeDir");
    }

    @Override
    public String getRechargeCallBack() {
        return prop.get("rechargeCallBack");
    }

    @Override
    public String getEnvProfile() {
        return prop.get("envProfile");
    }

    //esb
    @Override
    public String getEsbHostPrefix() {
        String esbHostPrefix = prop.get("esbHostPrefix");
        String esbSwitch = prop.get("esbHostPreTestSwitch");
        if("true".equals(esbSwitch)){
            esbHostPrefix=esbHostPrefix.replace("/dzg/","/pretest_dzg/"); //替换为预发布地址
        }
        return esbHostPrefix;
    }

    //rest
    @Override
    public String getRestHostPrefix() {
        String restHostPrefix = prop.get("restHostPrefix");
        String restSwitch = prop.get("restHostPreTestSwitch");
        if("true".equals(restSwitch)){
            restHostPrefix=restHostPrefix.replace("/dzg/","/pretest_dzg/"); //替换为预发布地址
        }
        return restHostPrefix;
    }

    @Override
    public String getAuthNoCheck() {
        return prop.get("authNoCheck");
    }

    //RefundUri
    @Override
    public String getRefundUri() {
        String refundUri = prop.get("refundUri");
        String refundUriSwitch = prop.get("refundUriPrefixSwitch");
        if("true".equals(refundUriSwitch)){
            refundUri=refundUri.replace("/dzg/","/pretest_dzg/"); //替换为预发布地址
        }
        return refundUri;
    }

//    @Override
//    public int getSessionExpireTime(){
//        return Integer.valueOf(prop.get("sessionExpireTime")).intValue();
//    }
}


